﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Maintenance.Views.GeneratedMonthsView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure">
    <UserControl.Resources>
        <converters:DateTimeToDateString x:Key="monthConverter" />
        <converters:ItemCountToString x:Key="itemCountToString" />

        <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="Padding" Value="10,0,0,0" />
        </Style>

        <CollectionViewSource x:Key="cvs" Source="{Binding ScheduledMonths, Path=ScheduledMonths.Months}">
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Month" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>

    </UserControl.Resources>

    <GroupBox Header="Genererade schemadagar:" Margin="15,0,0,0" Padding="0,10,5,5" VerticalAlignment="Top">

        <StackPanel Orientation="Vertical" VerticalAlignment="Top" Margin="5,5,5,5">

            <StackPanel Orientation="Horizontal" VerticalAlignment="Top" x:Name="stackPanelDates">

                <ListView x:Name="listViewMonths" BorderThickness="1" Width="200" MaxHeight="540" BorderBrush="AliceBlue" 
                          VerticalAlignment="Top" ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                          ScrollViewer.VerticalScrollBarVisibility="Auto"
                          ItemsSource="{Binding Source={StaticResource cvs}}"
                          ItemContainerStyle="{StaticResource ListViewItemStyle}" >
                    <ListView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.ContainerStyle>
                                <Style TargetType="{x:Type GroupItem}">
                                    <Setter Property="Margin" Value="0,0,0,5"/>
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="{x:Type GroupItem}">
                                                <Expander IsExpanded="False" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1">
                                                    <Expander.Header>
                                                        <DockPanel>
                                                            <TextBlock FontWeight="Bold" Text="{Binding Path=Name}" />
                                                            <TextBlock FontWeight="Bold" Text="{Binding Path=ItemCount, Converter={StaticResource itemCountToString}}" Margin="10,0,0,0" />
                                                        </DockPanel>
                                                    </Expander.Header>
                                                    <Expander.Content>
                                                        <ItemsPresenter />
                                                    </Expander.Content>
                                                </Expander>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </GroupStyle.ContainerStyle>
                        </GroupStyle>
                    </ListView.GroupStyle>
                    <ListView.View>
                        <GridView>
                            <GridView.ColumnHeaderContainerStyle>
                                <Style>
                                    <Setter Property="FrameworkElement.Visibility" Value="Collapsed" />
                                </Style>
                            </GridView.ColumnHeaderContainerStyle>
                            <GridViewColumn DisplayMemberBinding="{Binding Path=Date, Converter={StaticResource monthConverter}}" Width="80" />
                            <GridViewColumn DisplayMemberBinding="{Binding Path=StartEndTime}" />
                        </GridView>
                    </ListView.View>
                </ListView>

            </StackPanel>

        </StackPanel>

    </GroupBox>
</UserControl>
